Imports System.Windows.Forms

Public Class FormUtil
  Public Shared Sub Busy(ByVal objCtrl As Control, ByVal bBusy As Boolean)
    Static objCursor As Cursor
    If bBusy Then
      objCursor = objCtrl.Cursor
      objCtrl.Cursor = System.Windows.Forms.Cursors.WaitCursor
    Else
      objCtrl.Cursor = objCursor
    End If

    'Try this
    Application.DoEvents()
  End Sub

  ''' <summary>
  ''' Determine the maximum size a certain control can have inside a form by maximizing the parent and 
  ''' </summary>
  ''' <param name="frm"></param>
  ''' <returns></returns>
  ''' <remarks></remarks>
  Public Shared Function GetFormMaximumClientSize(ByVal frm As Form) As Drawing.Size
    Dim rectScreen As Drawing.Rectangle = Screen.PrimaryScreen.WorkingArea
    Dim currentSize As Drawing.Size = frm.Size
    frm.Width = rectScreen.Width
    frm.Height = rectScreen.Height - 40 'Dunno why, but we need to subtract 20
    Dim maxSize As Drawing.Size = frm.ClientSize
    frm.Size = currentSize
    Return maxSize
  End Function

End Class
